/*
 * Copyright 2008 Federal Emergency Management Agency
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at 
 * 
 *    http://www.apache.org/licenses/LICENSE-2.0 
 *    
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and 
 * limitations under the License. 
 *  
 */
package gov.fema.hazus.bdc.shared.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Transient;

@Entity
public class Building implements Serializable {
	
	@Id Long id;
	private Date lastMod;
	private String name;
	private String number;
	private String abbreviation;
	private String occupancy;
	private String buildingType;
	private Integer area = 0;
	private Integer constructionYear = 0;
	private Integer stories = 0;
	private String userName = "";
    private String mode = "";
	private ArrayList<String> terms = new ArrayList<String>();
	
	@Transient private AEBMResults aebmResults;
	@Transient private Address address;
	@Transient private Location location;
	@Transient private Contact contact;
	@Transient private Economy economy;
	@Transient private Capacity capacity;
	@Transient private Bracing bracing;
	@Transient private EarthquakeHazard earthquakeHazard;
	@Transient private EarthquakeBuildingDesign earthquakeBuildingDesign;
	@Transient private EarthquakeSecondaryCharacteristics earthquakeSecondaryCharacteristics;
	@Transient private FloodBasement floodBasement;
	@Transient private FloodBuildingDesign floodBuildingDesign;
	@Transient private FloodHazard floodHazard;
	@Transient private ManufacturedHousing manufacturedHousing;
	@Transient private Roof roof;
	@Transient private WallsAndOpenings wallsAndOpenings;
	@Transient private WindBuildingDesign windBuildingDesign;
	@Transient private WindHazard windHazard;
    
    private ArrayList<Note> notes = new ArrayList<Note>();
    
    
	// constants
    public static final String READ_ONLY = "read-only";
    public static final String EDITABLE = "editable"; // default
	public static final String NAME = "name";
	public static final String NUMBER = "number";
	public static final String ABBREVIATION = "abbreviation";
	public static final String OCCUPANCY = "occupancy";
	public static final String BUILDINGTYPE = "building type";
	public static final String AREA = "area";
	public static final String CONSTRUCTIONYEAR = "construction year";
	public static final String STORIES = "stories";
	
	public Building()
	{
		
	}
	
	public Building(String name, String number) {
        super();
        this.name = name;
        this.number = number;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public Date getLastMod() {
		return lastMod;
	}


	public void setLastMod(Date lastMod) {
		this.lastMod = lastMod;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public String getNumber() {
		return number;
	}

	public void setNumber(String number) {
		this.number = number;
	}
	
	public String getAbbreviation() {
		return abbreviation;
	}

	public void setAbbreviation(String abbreviation) {
		this.abbreviation = abbreviation;
	}

	public Address getAddress() {
		return address;
	}

	public void setAddress(Address address) {
		this.address = address;
	}

	public Location getLocation() {
		return location;
	}

	public void setLocation(Location location) {
		this.location = location;
	}
	
	public Contact getContact() {
		return contact;
	}

	public void setContact(Contact contact) {
		this.contact = contact;
	}

	public Integer getArea() {
		return area;
	}

	public void setArea(Integer area) {
		this.area = area;
	}

	public String getBuildingType() {
		return buildingType;
	}

	public void setBuildingType(String buildingType) {
		this.buildingType = buildingType;
	}

	public Integer getConstructionYear() {
		return constructionYear;
	}

	public void setConstructionYear(Integer constructionYear) {
		this.constructionYear = constructionYear;
	}

	public String getOccupancy() {
		return occupancy;
	}

	public void setOccupancy(String occupancy) {
		this.occupancy = occupancy;
	}

	public Integer getStories() {
		return stories;
	}

	public void setStories(Integer stories) {
		this.stories = stories;
	}

	public Economy getEconomy() {
		return economy;
	}

	public void setEconomy(Economy economy) {
		this.economy = economy;
	}

	public Capacity getCapacity() {
		return capacity;
	}

	public void setCapacity(Capacity capacity) {
		this.capacity = capacity;
	}

	public Bracing getBracing() {
		return bracing;
	}

	public void setBracing(Bracing bracing) {
		this.bracing = bracing;
	}

	public EarthquakeHazard getEarthquakeHazard() {
		return earthquakeHazard;
	}

	public void setEarthquakeHazard(EarthquakeHazard earthquakeHazard) {
		this.earthquakeHazard = earthquakeHazard;
	}

	public EarthquakeBuildingDesign getEarthquakeBuildingDesign() {
		return earthquakeBuildingDesign;
	}

	public void setEarthquakeBuildingDesign(
			EarthquakeBuildingDesign earthquakeBuildingDesign) {
		this.earthquakeBuildingDesign = earthquakeBuildingDesign;
	}

	public EarthquakeSecondaryCharacteristics getEarthquakeSecondaryCharacteristics() {
		return earthquakeSecondaryCharacteristics;
	}

	public void setEarthquakeSecondaryCharacteristics(
			EarthquakeSecondaryCharacteristics earthquakeSecondaryCharacteristics) {
		this.earthquakeSecondaryCharacteristics = earthquakeSecondaryCharacteristics;
	}

	public FloodBasement getFloodBasement() {
		return floodBasement;
	}

	public void setFloodBasement(FloodBasement floodBasement) {
		this.floodBasement = floodBasement;
	}

	public FloodBuildingDesign getFloodBuildingDesign() {
		return floodBuildingDesign;
	}

	public void setFloodBuildingDesign(FloodBuildingDesign floodBuildingDesign) {
		this.floodBuildingDesign = floodBuildingDesign;
	}

	public FloodHazard getFloodHazard() {
		return floodHazard;
	}

	public void setFloodHazard(FloodHazard floodHazard) {
		this.floodHazard = floodHazard;
	}

	public ManufacturedHousing getManufacturedHousing() {
		return manufacturedHousing;
	}

	public void setManufacturedHousing(ManufacturedHousing manufacturedHousing) {
		this.manufacturedHousing = manufacturedHousing;
	}

	public Roof getRoof() {
		return roof;
	}

	public void setRoof(Roof roof) {
		this.roof = roof;
	}

	public WallsAndOpenings getWallsAndOpenings() {
		return wallsAndOpenings;
	}

	public void setWallsAndOpenings(WallsAndOpenings wallsAndOpenings) {
		this.wallsAndOpenings = wallsAndOpenings;
	}

	public WindBuildingDesign getWindBuildingDesign() {
		return windBuildingDesign;
	}

	public void setWindBuildingDesign(WindBuildingDesign windBuildingDesign) {
		this.windBuildingDesign = windBuildingDesign;
	}

	public WindHazard getWindHazard() {
		return windHazard;
	}

	public void setWindHazard(WindHazard windHazard) {
		this.windHazard = windHazard;
	}


    /**
     * @return the mode
     */
    public String getMode() {
        return mode;
    }

    /**
     * @param mode the mode to set
     */
    public void setMode(String mode) {
        this.mode = mode;
    }

    /**
     * @return the aebmResults
     */
    public AEBMResults getAebmResults() {
        return aebmResults;
    }

    /**
     * @param aebmResults the aebmResults to set
     */
    public void setAebmResults(AEBMResults aebmResults) {
        this.aebmResults = aebmResults;
    }

    /**
     * @return the notes
     */
    public ArrayList<Note> getNotes() {
        return notes;
    }

    /**
     * @param notes the notes to set
     */
    public void setNotes(ArrayList<Note> notes) {
        this.notes = notes;
    }

    public String toString()
	{
		String str = "";
		str += "[building";
		str += "[id="+this.getId()+"]";
		//str += "[version="+this.getVersion()+"]";
        str += "[mode="+this.getMode()+"]";
        
        str += "[username="+this.getUserName()+"]";

		str += "[name="+this.name+"]";
		str += "[number="+this.number+"]";
		str += "[abbreviation="+this.abbreviation+"]";
		
		if( this.address != null )
		{
			str += this.address;
		}
		else
		{
			str += "[address=null]";
		}
        
        
		if( this.location != null )
		{
			str += this.location;
		}
		else
		{
			str += "[location=null]";
		}	
		if( this.contact != null )
		{
			str += this.contact;
		}
		else
		{
			str += "[contact=null]";
		}
		if( this.occupancy != null )
		{
			str += this.occupancy;
		}
		else
		{
			str += "[occupancy=null]";
		}	
		if( this.buildingType != null )
		{
			str += "[building-type="+this.buildingType+"]";
		}
		else
		{
			str += "[building-type=null]";
		}	
		if( this.area != null )
		{
			str += "[area="+this.area+"]";
		}
		else
		{
			str += "[area=null]";
		}
		if( this.constructionYear != null )
		{
			str += "[construction-year="+this.constructionYear+"]";
		}
		else
		{
			str += "[construction-year=null]";
		}
		if( this.stories != null )
		{
			str += "[stories="+this.stories+"]";
		}
		else
		{
			str += "[stories=null]";
		}
		if( this.economy != null )
		{
			str += this.economy;
		}
		else
		{
			str += "[economy=null]";
		}	
		if( this.capacity != null )
		{
			str += this.capacity;
		}
		else
		{
			str += "[capacity=null]";
		}	
		if( this.bracing != null )
		{
			str += this.bracing;
		}
		else
		{
			str += "[bracing=null]";
		}
		if( this.earthquakeHazard != null )
		{
			str += this.earthquakeHazard;
		}
		else
		{
			str += "[earthquake-hazard=null]";
		}
		if( this.earthquakeBuildingDesign != null )
		{
			str += this.earthquakeBuildingDesign;
		}
		else
		{
			str += "[earthquake-building-design=null]";
		}
		if( this.floodBasement != null )
		{
			str += this.floodBasement;
		}
		else
		{
			str += "[flood-basement=null]";
		}	
		if( this.floodBuildingDesign != null )
		{
			str += this.floodBuildingDesign;
		}
		else
		{
			str += "[flood-building-design=null]";
		}
		if( this.floodHazard != null )
		{
			str += this.floodHazard;
		}
		else
		{
			str += "[flood-hazard-design=null]";
		}
		if( this.manufacturedHousing != null )
		{
			str += this.manufacturedHousing;
		}
		else
		{
			str += "[manufactured-housing=null]";
		}	
		if( this.roof != null )
		{
			str += this.roof;
		}
		else
		{
			str += "[roof=null]";
		}		
		if( this.wallsAndOpenings != null )
		{
			str += this.wallsAndOpenings;
		}
		else
		{
			str += "[walls-and-openings=null]";
		}
		if( this.windBuildingDesign != null )
		{
			str += this.windBuildingDesign;
		}
		else
		{
			str += "[wind-building-design=null]";
		}		
		if( this.windHazard != null )
		{
			str += this.windHazard;
		}
		else
		{
			str += "[wind-hazard=null]";
		}		
		str += "]";
        if( this.aebmResults != null )
        {
            str += this.aebmResults;
        }
        else
        {
            str += "[aebm-results=null]";
        }    
        
        if( this.notes != null )
        {
            str += this.notes;
        }
        else
        {
            str += "[notes=null]";
        } 
        str += "]";        
		return str;
	}

	public void setTerms(ArrayList<String> terms) {
		this.terms = terms;
	}

	public ArrayList<String> getTerms() {
		return terms;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}





	

}
